package com.beiding.hotcode.v2;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

class UnsafeUtils {


    public static Unsafe unsafe;
    static {
        try {
            Field f = Unsafe.class.getDeclaredField("theUnsafe");
            f.setAccessible(true);
            unsafe = (Unsafe) f.get(null);
        } catch (Exception e) {
        }
    }


    static Object forceNew(Class type) {
        try {
            return unsafe.allocateInstance(type);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }


}
